<template>
  <view class="flex-table">
    <view class="flex-tr">
      <view class="flex-td--label">申请单位</view>
      <view class="flex-td--value flex-center">{{ ticket.applyUnitName }}</view>
      <view class="flex-td--label">设备名称</view>
      <view class="flex-td--value flex-center">{{ detail.position }}</view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">作业实施时间</view>
      <view class="flex-td--value flex-center">{{ actualDateLabel }}</view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">作业内容</view>
      <view class="flex-td--value flex-center">{{ ticket.workContent }}</view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">项目负责人</view>
      <view class="flex-td--value" style="display: block">
        <image
          v-for="imgItem in disclosureSignatures"
          :key="imgItem"
          :src="`${staticUrl}${imgItem}`"
          mode="aspectFill"
          class="signature__img"
          @click="handlePreviewImage(`${staticUrl}${imgItem}`, disclosureSignatures)"
        ></image>
      </view>
      <view class="flex-td--label">监护人</view>
      <view class="flex-td--value" style="display: block">
        <image
          v-for="imgItem in measuresSignature"
          :key="imgItem"
          :src="`${staticUrl}${imgItem}`"
          mode="aspectFill"
          class="signature__img"
          @click="handlePreviewImage(`${staticUrl}${imgItem}`, measuresSignature)"
        ></image>
      </view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">作业单位</view>
      <view class="flex-td--value flex-center">
        {{ ticket.unitName }}
      </view>
      <view class="flex-td--label">作业负责人</view>
      <view class="flex-td--value" style="display: block">
        <image
          v-for="imgItem in operatorManagerAcceptConfessionsSignatures"
          :key="imgItem"
          :src="`${staticUrl}${imgItem}`"
          mode="aspectFill"
          class="signature__img"
          @click="handlePreviewImage(`${staticUrl}${imgItem}`, operatorManagerAcceptConfessionsSignatures)"
        ></image>
      </view>
    </view>

    <view class="flex-tr">
      <view class="flex-td--label">作业人员</view>
      <view class="flex-td--value" style="display: block">
        <image
          v-for="imgItem in operatorAcceptConfessionsSignatures"
          :key="imgItem"
          :src="`${staticUrl}${imgItem}`"
          mode="aspectFill"
          class="signature__img"
          @click="handlePreviewImage(`${staticUrl}${imgItem}`, operatorAcceptConfessionsSignatures)"
        ></image>
      </view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">关联的其他特殊作业及安全作业票编号</view>
      <view class="flex-td--value flex-center">{{ relevanceTicketLabel }}</view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">风险辨识结果</view>
      <view class="flex-td--value flex-center">{{ ticket.riskIdentificationResultLabel }}</view>
    </view>
    <view class="flex-tr">
      <view class="flex-td--label">工艺交出条件（应关、应开阀门，水封、置换、清洗、盲板位置图等）</view>
      <view class="flex-td--value" style="line-height: 24px">
        <view>工艺：{{ detail.craft }} </view>
        <view class="flex items-start" v-if="craftImages.length">
          <text>附图：</text>
          <image
            v-for="imgItem in craftImages"
            :src="`${staticUrl}${imgItem}`"
            :key="imgItem"
            mode="aspectFill"
            class="complete__img"
            @click="handlePreviewImage(`${staticUrl}${imgItem}`, craftImages)"
          ></image>
        </view>
        <view class="flex items-center">
          <text>交出人：{{ detail.creatorLabel }}</text>
          <image
            v-for="imgItem in craftSign"
            :key="imgItem"
            :src="`${staticUrl}${imgItem}`"
            mode="aspectFill"
            class="signature__img"
            @click="handlePreviewImage(`${staticUrl}${imgItem}`, craftSign)"
          ></image>
          <text style="margin-left: 100px">
            交出时间：{{ $u.timeFormat(createTime, 'yyyy 年 mm 月 dd 日 hh 时 MM 分') }}
          </text>
        </view>
      </view>
    </view>
  </view>
</template>
<script>
import ticketTableMixin from './ticketTableMixin'
import { actNodeTypeEnum } from '@/utils/constant'
export default {
  mixins: [ticketTableMixin],
  props: {
    ticketId: [Number, String],
    detail: {
      type: Object,
      default: () => ({})
    },
    inspect: {
      type: Object,
      default: () => ({})
    },
    signatures: {
      type: Array,
      default: () => []
    },
    ticket: {
      type: Object,
      default: () => ({})
    },
    relevanceTicketLabel: String,
    riskIdentificationResult: String,
    actualDateLabel: String
  },
  computed: {
    createTime() {
      let key = actNodeTypeEnum.GY
      if (!this.inspect || !this.inspect[key]) return
      return this.inspect[key][0].createTime
    },
    craftSign() {
      let key = actNodeTypeEnum.GY
      if (!this.inspect || !this.inspect[key]) return []
      let signatures = this.inspect[key][0].signatures
      let s = []
      if (signatures[0] && signatures[0].signatureUrls) {
        s.push(signatures[0].signatureUrls)
      }

      return s
    },
    craftImages() {
      let images
      if (this.detail.images && this.detail.images.length > 0) {
        images = this.detail.images
      } else {
        images = []
      }
      let result = images.length > 0 ? images[0].split(',') : []
      return result
    }
  }
}
</script>
<style scoped lang="scss">
@import './style.scss';
</style>
